table of contents
SAR(1) | Linux User's Manual | SAR(1) |
NAME¶
sar - Collect, report, or save system activity information.
SYNOPSIS¶
sar [ -A ] [ -B ] [ -b ] [ -C ] [ -d ] [ -F ] [ -H ] [ -h ] [ -p ] [ -q ] [ -R ] [ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ] [ -I { int [,...] | SUM | ALL | XALL } ] [ -P { cpu [,...] | ALL } ] [ -m { keyword [,...] | ALL } ] [ -n { keyword [,...] | ALL } ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ -f [ filename ] | -o [ filename ] | -[0-9]+ ] [ -i interval ] [ -s [ hh:mm:ss ] ] [ -e [ hh:mm:ss ] ] [ interval [ count ] ]
DESCRIPTION¶
The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters, writes information the specified number of times spaced at the specified intervals in seconds. If the interval parameter is set to zero, the sar command displays the average statistics for the time since the system was started. If the interval parameter is specified without the count parameter, then reports are generated continuously. The collected data can also be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen. If filename is omitted, sar uses the standard system activity daily data file, the /var/log/sa/sadd file, where the dd parameter indicates the current day. By default all the data available from the kernel are saved in the data file.
The sar command extracts and writes to standard output records previously saved in a file. This file can be either the one specified by the -f flag or, by default, the standard system activity daily data file. It is also possible to enter -1, -2 etc. as an argument to sar to display data of that days ago. For example, -1 will point at the standard system activity file of yesterday.
Without the -P flag, the sar command reports system-wide (global among all processors) statistics, which are calculated as averages for values expressed as percentages, and as sums otherwise. If the -P flag is given, the sar command reports activity which relates to the specified processor or processors. If -P ALL is given, the sar command reports statistics for each individual processor and global statistics among all processors.
You can select information about specific system activities using flags. Not specifying any flags selects only CPU activity. Specifying the -A flag selects all possible activities.
The default version of the sar command (CPU utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system resources. If CPU utilization is near 100 percent (user + nice + system), the workload sampled is CPU-bound.
If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command. Run the sar command as a background process. The syntax for this is:
sar -o datafile interval count >/dev/null 2>&1 &
All data are captured in binary form and saved to a file (datafile). The data can then be selectively displayed with the sar command using the -f option. Set the interval and count parameters to select count records at interval second intervals. If the count parameter is not set, all the records saved in the file will be selected. Collection of data in this manner is useful to characterize system usage over a period of time and determine peak usage hours.
Note: The sar command only reports on local activities.
OPTIONS¶
- -A
- This is equivalent to specifying -bBdFHqrRSuvwWy -I SUM -I XALL -m ALL -n ALL -u ALL -P ALL.
- -B
- Report paging statistics. The following values are displayed:
pgpgin/s
pgpgout/s
fault/s
majflt/s
pgfree/s
pgscank/s
pgscand/s
pgsteal/s
%vmeff
- -b
- Report I/O and transfer rate statistics. The following values are
displayed:
tps
rtps
wtps
bread/s
bwrtn/s
- -C
- When reading data from a file, tell sar to display comments that have been inserted by sadc.
- -d
- Report activity for each block device. When data are displayed, the device
specification dev m-n is generally used ( DEV column).
m is the major number of the device and n its minor number.
Device names may also be pretty-printed if option -p is used or persistent
device names can be printed if option -j is used (see below). Note that
disk activity depends on sadc options "-S DISK" and "-S
XDISK" to be collected. The following values are displayed:
tps
rd_sec/s
wr_sec/s
avgrq-sz
avgqu-sz
await
svctm
%util
- -e [ hh:mm:ss ]
- Set the ending time of the report. The default ending time is 18:00:00. Hours must be given in 24-hour format. This option can be used when data are read from or written to a file (options -f or -o).
- -F [ MOUNT ]
- Display statistics for currently mounted filesystems. Pseudo-filesystems
are ignored. At the end of the report, sar will display a summary
of all those filesystems. Note that filesystems statistics depend on
sadc option -S XDISK to be collected. Use of the
MOUNT parameter keyword indicates that mountpoint will be reported
instead of filesystem device.
The following values are displayed:
MBfsfree
MBfsused
%fsused
%ufsused
Ifree
Iused
%Iused
- -f [ filename ]
- Extract records from filename (created by the -o filename flag). The default value of the filename parameter is the current daily data file, the /var/log/sa/sadd file. The -f option is exclusive of the -o option.
- -H
- Report hugepages utilization statistics. The following values are
displayed:
kbhugfree
kbhugused
%hugused
- -h
- Display a short help message then exit.
- -I { int [,...] | SUM | ALL | XALL }
- Report statistics for a given interrupt. int is the interrupt number. Specifying multiple -I int parameters on the command line will look at multiple independent interrupts. The SUM keyword indicates that the total number of interrupts received per second is to be displayed. The ALL keyword indicates that statistics from the first 16 interrupts are to be reported, whereas the XALL keyword indicates that statistics from all interrupts, including potential APIC interrupt sources, are to be reported. Note that interrupt statistics depend on sadc option "-S INT" to be collected.
- -i interval
- Select data records at seconds as close as possible to the number specified by the interval parameter.
- -j { ID | LABEL | PATH | UUID | ... }
- Display persistent device names. Use this option in conjunction with option -d. Options ID, LABEL, etc. specify the type of the persistent name. These options are not limited, only prerequisite is that directory with required persistent names is present in /dev/disk. If persistent name is not found for the device, the device name is pretty-printed (see option -p below).
- -m { keyword [,...] | ALL }
- Report power management statistics. Note that these statistics depend on
sadc option "-S POWER" to be collected.
Possible keywords are CPU, FAN, FREQ, IN, TEMP and USB.
With the CPU keyword, statistics about CPU are reported. The following value is displayed:
MHz
With the FAN keyword, statistics about fans speed are reported. The following values are displayed:
rpm
drpm
DEVICE
With the FREQ keyword, statistics about CPU clock frequency are reported. The following value is displayed:
wghMHz
With the IN keyword, statistics about voltage inputs are reported. The following values are displayed:
inV
%in
DEVICE
With the TEMP keyword, statistics about devices temperature are reported. The following values are displayed:
degC
%temp
DEVICE
With the USB keyword, the sar command takes a snapshot of all the USB devices currently plugged into the system. At the end of the report, sar will display a summary of all those USB devices. The following values are displayed:
BUS
idvendor
idprod
maxpower
manufact
product
- -n { keyword [,...] | ALL }
- Report network statistics.
Possible keywords are DEV, EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP, ETCP, UDP, SOCK6, IP6, EIP6, ICMP6, EICMP6 and UDP6.
With the DEV keyword, statistics from the network devices are reported. The following values are displayed:
IFACE
rxpck/s
txpck/s
rxkB/s
txkB/s
rxcmp/s
txcmp/s
rxmcst/s
With the EDEV keyword, statistics on failures (errors) from the network devices are reported. The following values are displayed:
IFACE
rxerr/s
txerr/s
coll/s
rxdrop/s
txdrop/s
txcarr/s
rxfram/s
rxfifo/s
txfifo/s
With the NFS keyword, statistics about NFS client activity are reported. The following values are displayed:
call/s
retrans/s
read/s
write/s
access/s
getatt/s
With the NFSD keyword, statistics about NFS server activity are reported. The following values are displayed:
scall/s
badcall/s
packet/s
udp/s
tcp/s
hit/s
miss/s
sread/s
swrite/s
saccess/s
sgetatt/s
With the SOCK keyword, statistics on sockets in use are reported (IPv4). The following values are displayed:
totsck
tcpsck
udpsck
rawsck
ip-frag
tcp-tw
With the IP keyword, statistics about IPv4 network traffic are reported. Note that IPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
irec/s
fwddgm/s
idel/s
orq/s
asmrq/s
asmok/s
fragok/s
fragcrt/s
With the EIP keyword, statistics about IPv4 network errors are reported. Note that IPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
ihdrerr/s
iadrerr/s
iukwnpr/s
idisc/s
odisc/s
onort/s
asmf/s
fragf/s
With the ICMP keyword, statistics about ICMPv4 network traffic are reported. Note that ICMPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
imsg/s
omsg/s
iech/s
iechr/s
oech/s
oechr/s
itm/s
itmr/s
otm/s
otmr/s
iadrmk/s
iadrmkr/s
oadrmk/s
oadrmkr/s
With the EICMP keyword, statistics about ICMPv4 error messages are reported. Note that ICMPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
ierr/s
oerr/s
idstunr/s
odstunr/s
itmex/s
otmex/s
iparmpb/s
oparmpb/s
isrcq/s
osrcq/s
iredir/s
oredir/s
With the TCP keyword, statistics about TCPv4 network traffic are reported. Note that TCPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
active/s
passive/s
iseg/s
oseg/s
With the ETCP keyword, statistics about TCPv4 network errors are reported. Note that TCPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
atmptf/s
estres/s
retrans/s
isegerr/s
orsts/s
With the UDP keyword, statistics about UDPv4 network traffic are reported. Note that UDPv4 statistics depend on sadc option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
idgm/s
odgm/s
noport/s
idgmerr/s
With the SOCK6 keyword, statistics on sockets in use are reported (IPv6). Note that IPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed:
tcp6sck
udp6sck
raw6sck
ip6-frag
With the IP6 keyword, statistics about IPv6 network traffic are reported. Note that IPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
irec6/s
fwddgm6/s
idel6/s
orq6/s
asmrq6/s
asmok6/s
imcpck6/s
omcpck6/s
fragok6/s
fragcr6/s
With the EIP6 keyword, statistics about IPv6 network errors are reported. Note that IPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
ihdrer6/s
iadrer6/s
iukwnp6/s
i2big6/s
idisc6/s
odisc6/s
inort6/s
onort6/s
asmf6/s
fragf6/s
itrpck6/s
With the ICMP6 keyword, statistics about ICMPv6 network traffic are reported. Note that ICMPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
imsg6/s
omsg6/s
iech6/s
iechr6/s
oechr6/s
igmbq6/s
igmbr6/s
ogmbr6/s
igmbrd6/s
ogmbrd6/s
irtsol6/s
ortsol6/s
irtad6/s
inbsol6/s
onbsol6/s
inbad6/s
onbad6/s
With the EICMP6 keyword, statistics about ICMPv6 error messages are reported. Note that ICMPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
ierr6/s
idtunr6/s
odtunr6/s
itmex6/s
otmex6/s
iprmpb6/s
oprmpb6/s
iredir6/s
oredir6/s
ipck2b6/s
opck2b6/s
With the UDP6 keyword, statistics about UDPv6 network traffic are reported. Note that UDPv6 statistics depend on sadc option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
idgm6/s
odgm6/s
noport6/s
idgmer6/s
The ALL keyword is equivalent to specifying all the keywords above and therefore all the network activities are reported.
- -o [ filename ]
- Save the readings in the file in binary form. Each reading is in a separate record. The default value of the filename parameter is the current daily data file, the /var/log/sa/sadd file. The -o option is exclusive of the -f option. All the data available from the kernel are saved in the file (in fact, sar calls its data collector sadc with the option "-S ALL". See sadc(8) manual page).
- -P { cpu [,...] | ALL }
- Report per-processor statistics for the specified processor or processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors. Note that processor 0 is the first processor.
- -p
- Pretty-print device names. Use this option in conjunction with option -d. By default names are printed as dev m-n where m and n are the major and minor numbers for the device. Use of this option displays the names of the devices as they (should) appear in /dev. Name mappings are controlled by /etc/sysconfig/sysstat.ioconf.
- -q
- Report queue length and load averages. The following values are displayed:
runq-sz
plist-sz
ldavg-1
ldavg-5
ldavg-15
blocked
- -R
- Report memory statistics. The following values are displayed:
frmpg/s
bufpg/s
campg/s
- -r
- Report memory utilization statistics. The following values are displayed:
kbmemfree
kbmemused
%memused
kbbuffers
kbcached
kbcommit
%commit
kbactive
kbinact
kbdirty
- -S
- Report swap space utilization statistics. The following values are
displayed:
kbswpfree
kbswpused
%swpused
kbswpcad
%swpcad
- -s [ hh:mm:ss ]
- Set the starting time of the data, causing the sar command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00:00. Hours must be given in 24-hour format. This option can be used only when data are read from a file (option -f ).
- -t
- When reading data from a daily data file, indicate that sar should display the timestamps in the original local time of the data file creator. Without this option, the sar command displays the timestamps in the user's locale time.
- -u [ ALL ]
- Report CPU utilization. The ALL keyword indicates that all the CPU
fields should be displayed. The report may show the following fields:
%user
%usr
%nice
%system
%sys
%iowait
%steal
%irq
%soft
%guest
%gnice
%idle
Note: On SMP machines a processor that does not have any activity at all (0.00 for every field) is a disabled (offline) processor.
- -V
- Print version number then exit.
- -v
- Report status of inode, file and other kernel tables. The following values
are displayed:
dentunusd
file-nr
inode-nr
pty-nr
- -W
- Report swapping statistics. The following values are displayed:
pswpin/s
pswpout/s
- -w
- Report task creation and system switching activity.
proc/s
cswch/s
- -y
- Report TTY device activity. The following values are displayed:
rcvin/s
xmtin/s
framerr/s
prtyerr/s
brk/s
ovrun/s
ENVIRONMENT¶
The sar command takes into account the following environment variables:
- S_TIME_FORMAT
- If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The sar command will use the ISO 8601 format (YYYY-MM-DD) instead.
- S_TIME_DEF_TIME
- If this variable exists and its value is UTC then sar will save its data in UTC time (data will still be displayed in local time). sar will also use UTC time instead of local time to determine the current daily data file located in the /var/log/sa directory. This variable may be useful for servers with users located across several timezones.
EXAMPLES¶
sar -u 2 5
sar -I 14 -o int14.file 2 10
sar -r -n DEV -f /var/log/sa/sa16
sar -A
BUGS¶
/proc filesystem must be mounted for the sar command to work.
All the statistics are not necessarily available, depending on the kernel version used. sar assumes that you are using at least a 2.6 kernel.
FILES¶
/var/log/sa/sadd
AUTHOR¶
Sebastien Godard (sysstat <at> orange.fr)
SEE ALSO¶
sadc(8), sa1(8), sa2(8), sadf(1), pidstat(1), mpstat(1), iostat(1), vmstat(8)
SEPTEMBER 2012 | Linux |